#include <iostream>
 
void func(void)
{
    std::cout<<"func(void) called"<<std::endl;
}
 
struct Foo
{
    void operator()(void)
    {
        std::cout<<"Foo::()(void) called"<<std::endl;
    }
};
 
struct Bar
{
    using ft_t = void(*)(void);
    static void func(void)
    {
        std::cout<<"Bar::func(void) called"<<std::endl;
    }
 
    operator ft_t(void)
    {
        return func;
    }
};
 
struct A
{
    int m_a;
    void mem_func(void)
    {
        std::cout<< "A:memfunc(void) called and m_a = " << m_a << std::endl;
    }
};
 
 
int main() {
    //1.函数指针
    void(* func_ptr)(void) = &func;
    func_ptr();
 
    //2.仿函数
    Foo foo;
    foo();
 
    //3.可被转换为函数指针的类对象
    Bar bar;
    bar();
 
    //4.类成员函数指针或类成员指针
    void (A::*mem_func_ptr)(void) = &A::mem_func;
    int A::*mem_obj_ptr = &A::m_a;
    A aa;
    (aa.*mem_obj_ptr) = 123;
    (aa.*mem_func_ptr)();
 
    return 0;
}

/*
func(void) called
Foo::()(void) called
Bar::func(void) called
A:memfunc(void) called and m_a = 123
*/
